<?php
global $Config;
require_once($Config->WebCMSRoot.'Base/View.php');

Class MediaView extends BaseView
{
	function MediaView()
	{
		parent::BaseView();
	}
	
	function PrintList(&$mediaList)
	{
		if (count($mediaList->Collection) > 0)
		{
			if (count($mediaList->Collection) > 1)
			{
				$jaar = $mediaList->Voorstelling->Collection[0]->Jaar;

				foreach ($mediaList->Collection as $key=>$media)
				{
// madia-icoon vooraf
					$this->output .= '<p>';
					$this->output .= '<a href="/media/'.$jaar.'/'.$media->ID.'">';
// thumbnail / image / screenshot
					switch ($media->Type)
					{
						case _MEDIATYPE_KRANT:
							$this->output .= 'Lees: ' . $media->Titel;
							break;
						case _MEDIATYPE_AUDIO:
							$this->output .= 'Beluister: ' . $media->Titel;
							break;
						case _MEDIATYPE_VIDEO:
							$this->output .= 'Bekijk: ' . $media->Titel;
							break;
						case _MEDIATYPE_OTHER:
							$this->output .= $media->Titel;;
							break;
					}
			  		$this->output .= '</a>';
					$this->output .= '<br /><span style="font-size:75%">(Bron: '.$media->Bron.')</span>';
					$this->output .= '</p>';
				}
			}
			else
			{
				$this->Show($mediaList->Collection[0]);
			}
		}
		else
		{
			$this->output .= '<span style="font-style:italic">Geen media gevonden.</span>';
		}
	}
	
	function Show(&$media)
	{
//print('<pre>'.var_export($media,true).'</pre>');exit;
		$location = '';
		
		//$this->output .= '<p>';
		
		if (isset($media))
		{
			if (strlen($media->URL) > 0)
			{
				$location = $media->URL;
			}
			else
			{
				$location = $media->File;
			}
			
			switch ($media->Type)
			{
				case _MEDIATYPE_KRANT:
					$this->output .= '<img src="'.$location.'" alt="'.$media->Titel.'" />';
					$this->output .= '<br />';
					if ($media->Transcription)
					{
						$this->output .= utf8_encode($media->Transcription);
					}
					break;
				case _MEDIATYPE_AUDIO:
					$this->output = '<a href="'.$location.'">Beluister '.$media->Titel.'</a>';
					break;
				case _MEDIATYPE_VIDEO:
					$this->output = '<a href="'.$location.'">Bekijk '.$media->Titel.'</a>';
					break;
				case _MEDIATYPE_OTHER:
					$this->output = '<a href="'.$location.'">Download '.$media->Titel.'</a>';
					break;
			}
		}
		else
		{
			$this->output .= 'Media not found.';
		}
		
		//$this->output .= '</p>';
	}
}
?>